package com.jic.market.controller.manage;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.api.manage.LotteryActivityApi;
import com.jic.market.common.exception.MarketException;
import com.jic.market.common.util.BeanUtil;
import com.jic.market.entity.LotteryTheme;
import com.jic.market.entity.MarketConfigEntity;
import com.jic.market.request.MarketConfJumpLinksRequest;
import com.jic.market.request.manager.lottery.*;
import com.jic.market.response.MarketConfJumpLinksResponse;
import com.jic.market.response.manager.lottery.LotteryActivityResponse;
import com.jic.market.response.manager.lottery.LotteryDrawRecordResponse;
import com.jic.market.response.manager.lottery.LotteryThemeResponse;
import com.jic.market.service.LotteryActivityService;
import com.jic.market.service.LotteryDrawRecordService;
import com.jic.market.service.LotteryThemeService;
import com.jic.market.service.MarketConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: MJ
 * @date: 2020-07-08
 * @remark: 营销中心配置表
 */
@RestController
@RequestMapping("/marketConfig")
@Api(tags = {"营销中心配置"})
@Slf4j
public class MarketConfigController{

    @Resource
    private MarketConfigService marketConfigService;


    /**
     * 第三方跳转链接配置
     * @param request
     * @return
     */
    @PostMapping("/thirdPartyJumpLinks")
    @ResponseBody
    @ApiOperation(value = "第三方跳转链接配置")
    public RestResult<String> thirdPartyJumpLinks(@RequestBody MarketConfJumpLinksRequest request) {
        try {
            RestResult restResult = marketConfigService.thirdPartyJumpLinks(request);
            return restResult;
        }catch (Exception e){
            log.error("Market thirdPartyJumpLinks error：",e);
            return RestResult.error("9999","系统异常，操作失败");
        }
    }


    /**
     * 获取当前组织第三方跳转链接配置
     * @param request
     * @return
     */
    @PostMapping("/getDeptJumpLinks")
    @ResponseBody
    @ApiOperation(value = "获取当前组织第三方跳转链接配置")
    public RestResult<MarketConfJumpLinksResponse> getDeptJumpLinks(@RequestBody MarketConfJumpLinksRequest request) {
        try {
            RestResult restResult = marketConfigService.getDeptJumpLinks(request);
            return restResult;
        }catch (Exception e){
            log.error("Market thirdPartyJumpLinks error：",e);
            return RestResult.error("9999","系统异常，操作失败");
        }
    }

}
